# -*- coding: utf-8 -*-
"""
@Env 
@Time 2024/9/3 上午10:55
@Author yzpang
@Function: 
"""
import traceback

from ..entity.request import EvaluateMessage
from ..entity.response import BaseResponse
from ..service import evaluate_service
from modelserver.configs.base_config import get_logger


def mount_evaluate_routes(app):
    """
    挂载评估相关接口
    :param app:
    """
    app.post(path="/evaluate/accuracy",
             tags=['evaluate accuracy'],
             summary="评估准确度",
             )(evaluate_accuracy)


def evaluate_accuracy(request: EvaluateMessage) -> BaseResponse:
    get_logger().info(request)
    try:
        result = evaluate_service.evaluate_accuracy(request)
        return BaseResponse(data=result)
    except Exception as e:
        traceback.print_exc()
        return BaseResponse(code=500, msg="failed", data=str(e))
